{
/* successful */
cexpr = CEXPR_close_curly(&list);
-#if DEBUG
assert (list.len == 0 && condition == NULL);
-#endif
}
else if (condition != NULL)
{
const char * b)
{
/* both a and b MUST be terminated strings */
-
-#if DEBUG
assert (a != NULL && b != NULL);
-#endif
switch (operator)
{
const int64_t a,
const int64_t b)
{
-#if DEBUG
assert ((a == 0 || a == 1) && (b == 0 || b == 1));
-#endif
+
switch (operator)
{
case CEXPR_EQ:
switch (cexpr->operator)
{
case CEXPR_AND:
-#if DEBUG
/* tp_a cannot be VIA_NULL, but tp_b can */
assert (cexpr->tp_a != VIA_NULL);
-#endif
return ((cexpr->tp_a == VIA_CEXPR) ?
cexpr_run(cexpr->via_a.cexpr, cb, obj) :
cb(obj, cexpr->via_a.cond)) &&
cexpr_run(cexpr->via_b.cexpr, cb, obj) :
cb(obj, cexpr->via_b.cond)));
case CEXPR_OR:
-#if DEBUG
/* both tp_a and tp_b can NEVER be VIA_NULL */
assert (cexpr->tp_a != VIA_NULL && cexpr->tp_b != VIA_NULL);
-#endif
return ((cexpr->tp_a == VIA_CEXPR) ?
cexpr_run(cexpr->via_a.cexpr, cb, obj) :
cb(obj, cexpr->via_a.cond)) ||
}
else
{
-#if DEBUG
assert (node->len == 2);
-#endif
switch (*node->str)
{
case '=': return CEXPR_EQ;
}
else
{
-#if DEBUG
- assert(cexpr->tp_b == VIA_NULL);
-#endif
+ assert(cexpr->tp_b == VIA_NULL);#endif
cexpr->tp_b = VIA_COND;
cexpr->via_b.cond = cond;
}
}
else
{
-#if DEBUG
assert(cexpr->tp_b == VIA_NULL);
-#endif
cexpr->tp_b = VIA_CEXPR;
cexpr->via_b.cexpr = new_cexpr;
}
static cexpr_t * CEXPR_close_curly(cexpr_list_t * list)
{
-#if DEBUG
assert (list->len > 0);
-#endif
list->len--;
return list->cexpr[list->len];
}
*/
static void CT_merge_node(ct_node_t * node)
{
-#if DEBUG
assert(node->size == 1 && node->data == NULL);
-#endif
-
ct_node_t * child_node;
char * tmp;
uint_fast16_t i, end;
*/
int imap_set(imap_t * imap, uint64_t id, void * data)
{
-#if DEBUG
/* insert NULL is not allowed */
assert (data != NULL);
-#endif
int rc;
imap_node_t * nd = imap->nodes + (id % IMAP_NODE_SZ);
id /= IMAP_NODE_SZ;
*/
int imap_add(imap_t * imap, uint64_t id, void * data)
{
-#if DEBUG
/* insert NULL is not allowed */
assert (data != NULL);
-#endif
+
imap_node_t * nd = imap->nodes + (id % IMAP_NODE_SZ);
id /= IMAP_NODE_SZ;
{
if (dest_nd->data != NULL)
{
-#if DEBUG
/* this must be the same object */
assert (imap_nd->data == dest_nd->data);
-#endif
/* we are sure there is a ref left */
slist_object_decref(imap_nd->data);
}
{
if (dest_nd->data != NULL)
{
-#if DEBUG
/* this must be the same object */
assert (imap_nd->data == dest_nd->data);
-#endif
+
/* we are sure to have one ref left */
slist_object_decref(dest_nd->data);
dest_nd->data = NULL;
{
if (dest_nd->data != NULL)
{
-#if DEBUG
/* this must be the same object */
assert (imap_nd->data == dest_nd->data);
-#endif
+
/* we are sure to have one ref left */
slist_object_decref(dest_nd->data);
{
if (dest_nd->data != NULL)
{
-#if DEBUG
/* this must be the same object */
assert (node_nd->data == dest_nd->data);
-#endif
/* we are sure there is a ref left */
slist_object_decref(node_nd->data);
}
{
if (dest_nd->data != NULL)
{
-#if DEBUG
/* this must be the same object */
assert (node_nd->data == dest_nd->data);
-#endif
/* we are sure to have one ref left */
slist_object_decref(dest_nd->data);
dest_nd->data = NULL;
{
if (dest_nd->data != NULL)
{
-#if DEBUG
/* this must be the same object */
assert (node_nd->data == dest_nd->data);
-#endif
+
/* we are sure to have one ref left */
slist_object_decref(dest_nd->data);
struct tm tm;
time_t ts;
-#if DEBUG
/* must be a valid timezone */
assert (tz >= 0 && tz < TZ_LEN);
/* timezone must be 0 (UTC) */
assert (timezone == 0);
-#endif
memset(&tm, 0, sizeof(struct tm));
+++ /dev/null
-/*
- * motd.c - Message of the day
- *
- * Note: all quotes are found somewhere on the Internet.
- *
- * author : Jeroen van der Heijden
- * email : jeroen@transceptor.technology
- * copyright : 2016, Transceptor Technology
- *
- * changes
- * - initial version, 13-03-2016
- *
- */
-#include <stdlib.h>
-#include <motd/motd.h>
-
-static const char * motd_messages[] = {
- "If God had intended Man to program, \n"
- "we'd be born with serial I/O ports.",
-
- "\"On the Internet, no one knows you're using Windows NT\"\n"
- "(Submitted by Ramiro Estrugo, restrugo@fateware.com)",
-
- "Your mail is being routed through Germany ...\n"
- "and they're censoring us.",
-
- "There's got to be more to life than compile-and-go.",
-
- "One person's error is another person's data.",
-
- "Nobody said computers were going to be polite.",
-
- "Little known fact about Middle Earth:\n"
- "The Hobbits had a very sophisticated computer network!\n\n"
- "It was a Tolkien Ring...",
-
- "You can do anything, but not everything.\n\n"
- "--David Allen",
-
- "Perfection is achieved, not when there is nothing more to add,\n"
- "but when there is nothing left to take away.\n\n"
- "--Antoine de Saint-Exupéry",
-
- "The richest man is not he who has the most,\n"
- "but he who needs the least.\n\n"
- "--Unknown Author",
-
- "You miss 100 percent of the shots you never take.\n\n"
- "--Wayne Gretzky",
-
- "Courage is not the absence of fear,\n"
- "but rather the judgment that something else is more "
- "important than fear.\n\n"
- "--Ambrose Redmoon",
-
- "Everyone is a genius at least once a year.\n"
- "The real geniuses simply have their bright ideas closer together.\n\n"
- "--Georg Christoph Lichtenberg",
-
- "Before I got married I had six theories about bringing up children;\n"
- "now I have six children and no theories.\n\n"
- "--John Wilmot",
-
- "Those who believe in telekinetics, raise my hand.\n\n"
- "--Kurt Vonnegut",
-
- "We've heard that a million monkeys at a million keyboards could "
- "produce the complete works of Shakespeare;\n"
- "now, thanks to the Internet, we know that is not true.\n\n"
- "--Robert Wilensky",
-
- "The person who reads too much and uses his brain too little will "
- "fall into lazy habits of thinking.\n\n"
- "--Albert Einstein",
-
- "Believe those who are seeking the truth. Doubt those who find it.\n\n"
- "--André Gide",
-
- "It is the mark of an educated mind to be able to entertain a thought "
- "without accepting it.\n\n"
- "--Aristotle",
-
- "Pure mathematics is, in its way, the poetry of logical ideas.\n\n"
- "--Albert Einstein",
-
- "Do not worry about your difficulties in Mathematics. "
- "I can assure you mine are still greater.\n\n"
- "--Albert Einstein",
-
- "While physics and mathematics may tell us how the universe began,\n"
- "they are not much use in predicting human behavior because there "
- "are far too many equations to solve.\n"
- "I'm no better than anyone else at understanding what makes people "
- "tick, particularly women.\n\n"
- "--Stephen Hawking",
-
- "'Obvious' is the most dangerous word in mathematics.\n\n"
- "--E. T. Bell",
-
- "Nobody ever figures out what life is all about, and it doesn't matter.\n"
- "Explore the world.\n"
- "Nearly everything is really interesting if you go into it deeply enough.\n\n"
- "--Richard Feynman",
-
- "Physics is like sex: sure, it may give some practical results, "
- "but that's not why we do it.\n\n"
- "--Richard Feynman",
-
- "You have no responsibility to live up to what other people think "
- "you ought to accomplish.\n"
- "I have no responsibility to be like they expect me to be.\n"
- "It's their mistake, not my failing.\n\n"
- "--Richard Feynman",
-
- "I learned very early the difference between knowing the name of "
- "something and knowing something.\n\n"
- "--Richard Feynman",
-
- "Religion is a culture of faith; science is a culture of doubt.\n\n"
- "--Richard Feynman",
-
- "I think it's much more interesting to live not knowing than to have "
- "answers which might be wrong.\n\n"
- "--Richard Feynman"
-
-};
-
-#define MOTD_SIZE (sizeof (motd_messages) / sizeof (const char *))
-
-const char * motd_get_random_msg(void)
-{
- return motd_messages[rand() % MOTD_SIZE];
-}
*/
void qp_unpacker_ff_free(qp_unpacker_t * unpacker)
{
-#if DEBUG
assert(unpacker != NULL);
-#endif
free(unpacker->source);
free(unpacker);
}
*/
void qp_packer_free(qp_packer_t * packer)
{
-#if DEBUG
assert(packer != NULL);
-#endif
free(packer->buffer);
free(packer);
}
*/
int qp_add_type(qp_packer_t * packer, qp_types_t tp)
{
-#if DEBUG
assert(tp >= QP_ARRAY0 && tp <= QP_MAP_CLOSE);
-#endif
-
QP_RESIZE(1)
packer->buffer[packer->len++] = tp;
return 0;
*/
int qp_fadd_type(qp_fpacker_t * fpacker, qp_types_t tp)
{
-#if DEBUG
assert(tp >= QP_ARRAY0 && tp <= QP_MAP_CLOSE);
-#endif
-
return (fputc(tp, fpacker) == (int) tp) ? 0 : EOF;
}
#define DEFAULT_LOG_FILE_MAX_SIZE 50000000
#define DEFAULT_LOG_FILE_NUM_BACKUPS 6
-#if DEBUG
+#ifndef NDEBUG
#define DEFAULT_LOG_LEVEL "debug"
#else
#define DEFAULT_LOG_LEVEL "info"
*/
int siri_backup_enable(siri_t * siri, siridb_t * siridb)
{
-#if DEBUG
assert (~siridb->server->flags & SERVER_FLAG_BACKUP_MODE);
assert (~siridb->server->flags & SERVER_FLAG_REINDEXING);
-#endif
llist_t * llist = (llist_t *) siri->backup->data;
int siri_backup_disable(siri_t * siri, siridb_t * siridb)
{
-#if DEBUG
assert (siridb->server->flags & SERVER_FLAG_BACKUP_MODE);
-#endif
int rc = 0;
siridb_aggr_t * aggr,
char * err_msg)
{
-#if DEBUG
assert (source->len);
-#endif
-
if (aggr->limit)
{
return AGGREGATE_limit(source, aggr, err_msg);
points->data = point;
}
}
-#if DEBUG
- else
- {
- /* if not smaller it must be equal */
- assert (points->len == max_sz);
- }
-#endif
+ /* else { assert (points->len == max_sz); } */
return points;
}
siridb_aggr_t * aggr,
char * err_msg)
{
-#if DEBUG
assert (points->len);
-#endif
if (points->tp == TP_STRING)
{
siridb_aggr_t * aggr __attribute__((unused)),
char * err_msg)
{
-#if DEBUG
assert (points->len);
-#endif
switch (points->tp)
{
siridb_aggr_t * aggr __attribute__((unused)),
char * err_msg)
{
-#if DEBUG
assert (points->len);
-#endif
if (points->tp == TP_STRING)
{
siridb_aggr_t * aggr __attribute__((unused)),
char * err_msg)
{
-#if DEBUG
assert (points->len);
-#endif
double sum = 0.0;
size_t i;
siridb_aggr_t * aggr __attribute__((unused)),
char * err_msg)
{
-#if DEBUG
assert (points->len);
-#endif
if (points->tp == TP_STRING)
{
siridb_aggr_t * aggr __attribute__((unused)),
char * err_msg)
{
-#if DEBUG
assert (points->len);
-#endif
if (points->tp == TP_STRING)
{
siridb_aggr_t * aggr __attribute__((unused)),
char * err_msg)
{
-#if DEBUG
assert (points->len);
-#endif
if (points->tp == TP_STRING)
{
siridb_aggr_t * aggr __attribute__((unused)),
char * err_msg)
{
-#if DEBUG
assert (points->len);
-#endif
if (points->tp == TP_STRING)
{
siridb_aggr_t * aggr __attribute__((unused)),
char * err_msg)
{
-#if DEBUG
assert (points->len);
-#endif
switch (points->tp)
{
siridb_aggr_t * aggr __attribute__((unused)),
char * err_msg)
{
-#if DEBUG
assert (points->len);
-#endif
switch (points->tp)
{
siridb_aggr_t * aggr __attribute__((unused)),
char * err_msg)
{
-#if DEBUG
assert (points->len);
-#endif
switch (points->tp)
{
siridb_aggr_t * aggr __attribute__((unused)),
char * err_msg)
{
-#if DEBUG
assert (points->len);
-#endif
switch (points->tp)
{
siridb_aggr_t * aggr __attribute__((unused)),
char * err_msg __attribute__((unused)))
{
-#if DEBUG
assert (points->len);
-#endif
+
siridb_point_t * source = points->data;
switch (points->tp)
siridb_aggr_t * aggr __attribute__((unused)),
char * err_msg __attribute__((unused)))
{
-#if DEBUG
assert (points->len);
-#endif
+
siridb_point_t * source = points->data + (points->len - 1);
switch (points->tp)
*/
void siridb__free(siridb_t * siridb)
{
-#if DEBUG
- log_debug("Free database: '%s'", siridb->dbname);
-#endif
-
/* first we should close the buffer and all other open files */
if (siridb->buffer != NULL)
{
siridb_ffile_t * ffile,
sirinet_pkg_t * pkg)
{
-#if DEBUG
assert (ffile->fp != NULL);
-#endif
uint32_t size = pkg->len + sizeof(sirinet_pkg_t);
*/
sirinet_pkg_t * siridb_ffile_pop(siridb_ffile_t * ffile)
{
-#if DEBUG
assert (ffile->next_size);
assert (ffile->fp != NULL);
-#endif
if (fseeko(
ffile->fp,
-(long int) (ffile->next_size + sizeof(uint32_t)),
*/
int siridb_ffile_pop_commit(siridb_ffile_t * ffile)
{
-#if DEBUG
assert (ffile->next_size && ffile->fp != NULL);
-#endif
ffile->size -= ffile->next_size + sizeof(uint32_t);
/* we have at least one fifo in the list */
fifo->out = (siridb_ffile_t *) llist_shift(fifo->fifos);
-#if DEBUG
assert (fifo->out != NULL);
-#endif
if (fifo->out->fp == NULL)
{
}
}
-#if DEBUG
assert (fifo->out != NULL);
-#endif
return siri_err;
}
*/
int siridb_fifo_close(siridb_fifo_t * fifo)
{
-#if DEBUG
assert (fifo->in->fp != NULL);
-#endif
int rc = 0;
/* close the 'in' fifo */
*/
int siridb_fifo_open(siridb_fifo_t * fifo)
{
-#if DEBUG
assert (fifo->in->fp == NULL);
-#endif
-
/* open fifo 'in' */
siridb_ffile_open(fifo->in, "r+");
/* free forward */
free(forward);
-
-#if DEBUG
- log_debug("Free forward!, hooray!");
-#endif
}
/*
{
size_t i;
-#if DEBUG
- log_debug("Free group: '%s'", group->name);
-#endif
free(group->name);
free(group->source);
static void GROUPS_free(siridb_groups_t * groups)
{
size_t i;
-
-#if DEBUG
- log_debug("Free groups");
-#endif
free(groups->fn);
if (groups->nseries != NULL)
siridb_series_t * series;
size_t i;
-#if DEBUG
/* do not run this function when no groups need initialization */
assert (siridb->groups->ngroups->len);
-#endif
uv_mutex_lock(&siridb->series_mutex);
{
group = (siridb_group_t *) slist_pop(groups->ngroups);
-#if DEBUG
/* we must be sure this group is empty */
assert (group->series->len == 0);
-#endif
if (~group->flags & GROUP_FLAG_DROPPED)
{
*/
static void INITSYNC_next_series_id(siridb_t * siridb)
{
-#if DEBUG
assert (siridb->replicate != NULL);
assert (siridb->replicate->status == REPLICATE_RUNNING ||
siridb->replicate->status == REPLICATE_STOPPING);
-#endif
siridb_initsync_t * initsync = siridb->replicate->initsync;
*/
static void INITSYNC_pause(siridb_replicate_t * replicate)
{
-#if DEBUG
assert (replicate->status == REPLICATE_STOPPING);
-#endif
if (fclose(replicate->initsync->fp))
{
log_critical("Error occurred while closing file: '%s'",
static void INITSYNC_send(uv_timer_t * timer)
{
siridb_t * siridb = (siridb_t *) timer->data;
-#if DEBUG
assert (siridb->replicate->initsync->pkg != NULL);
-#endif
if (siridb->replicate->status == REPLICATE_STOPPING)
{
static void INITSYNC_work(uv_timer_t * timer)
{
siridb_t * siridb = (siridb_t *) timer->data;
-#if DEBUG
+
assert (siridb->replicate->status == REPLICATE_RUNNING ||
siridb->replicate->status == REPLICATE_STOPPING);
assert (siridb->replicate->initsync != NULL);
assert (siridb->replicate->initsync->fp != NULL);
assert (siridb->replicate->initsync->pkg == NULL);
-#endif
if (siridb->insert_tasks)
{
*/
static int INITSYNC_unlink(siridb_initsync_t * initsync)
{
-#if DEBUG
assert (initsync->fp != NULL);
-#endif
fclose(initsync->fp);
initsync->fp = NULL;
/* free insert */
free(insert);
-
-#if DEBUG
- log_debug("Free insert!, hooray!");
-#endif
}
/*
sirinet_pkg_t * pkg,
int status)
{
-#if DEBUG
assert (pkg == NULL);
-#endif
pkg = sirinet_pkg_new(
0,
0,
sirinet_pkg_t * pkg,
int status)
{
-#if DEBUG
assert (pkg == NULL);
-#endif
sirinet_stream_t * client = promise->data;
pkg = sirinet_pkg_new(
* the previous correct pool. (we can do this now
* because we known we don't have the series)
*/
-#if DEBUG
assert (siridb->pools->prev_lookup != NULL);
-#endif
pool = siridb_lookup_sn_raw(
siridb->pools->prev_lookup,
(const char *) qp_series_name->via.raw,
siridb_user_t * db_user = query->client->origin;
SIRIPARSER_MASTER_CHECK_ACCESS(db_user, SIRIDB_ACCESS_ALTER)
-#if DEBUG
assert (query->packer == NULL);
-#endif
query->packer = sirinet_packer_new(1024);
siridb_user_t * db_user = query->client->origin;
SIRIPARSER_MASTER_CHECK_ACCESS(db_user, SIRIDB_ACCESS_COUNT)
-#if DEBUG
assert (query->packer == NULL);
-#endif
query->packer = sirinet_packer_new(256);
siridb_query_t * query = (siridb_query_t *) handle->data;
siridb_user_t * db_user = query->client->origin;
-#if DEBUG
assert (query->packer == NULL);
-#endif
SIRIPARSER_MASTER_CHECK_ACCESS(db_user, SIRIDB_ACCESS_DROP)
siridb_user_t * db_user = query->client->origin;
SIRIPARSER_MASTER_CHECK_ACCESS(db_user, SIRIDB_ACCESS_LIST)
-#if DEBUG
assert (query->packer == NULL);
-#endif
query->packer = sirinet_packer_new(QP_SUGGESTED_SIZE);
SIRIPARSER_MASTER_CHECK_ACCESS(db_user, SIRIDB_ACCESS_SELECT)
MASTER_CHECK_ACCESSIBLE(siridb)
-#if DEBUG
assert (query->packer == NULL && query->data == NULL);
-#endif
query->data = q_select = query_select_new();
siridb_query_t * query = (siridb_query_t *) handle->data;
cleri_node_t * calc_node = query->nodes->node;
-#if DEBUG
assert (query->packer == NULL);
-#endif
query->packer = sirinet_packer_new(64);
}
else
{
-#if DEBUG
assert (query->packer == NULL);
-#endif
query->packer = sirinet_packer_new(1024);
if (query->packer == NULL)
{
cleri_node_t * user_node =
query->nodes->node->children->next->node;
-#if DEBUG
/* both name and packer should be NULL at this point */
assert(user->name == NULL);
assert(query->packer == NULL);
-#endif
MASTER_CHECK_ACCESSIBLE(siridb)
/* success, increment the user reference counter */
siridb_user_incref(user);
-#if DEBUG
assert (query->packer == NULL);
-#endif
query->packer = sirinet_packer_new(1024);
if (query->packer == NULL)
return;
}
-#if DEBUG
assert (query->packer == NULL);
-#endif
query->packer = sirinet_packer_new(1024);
if (query->data != NULL)
{
-#if DEBUG
assert (query->packer == NULL);
-#endif
const char * help = siri_help_get(
query->nodes->node->cl_obj->gid,
(const char *) query->data,
return;
}
-#if DEBUG
assert (query->packer == NULL);
-#endif
query->packer = sirinet_packer_new(1024);
siridb_query_t * query = (siridb_query_t *) handle->data;
siridb_t * siridb = query->client->siridb;
-#if DEBUG
assert (query->data != NULL);
assert (IS_MASTER);
-#endif
siridb_server_t * server = ((query_alter_t *) query->data)->via.server;
query_alter_t * q_alter = (query_alter_t *) query->data;
siridb_t * siridb = query->client->siridb;
-#if DEBUG
assert (query->data != NULL);
-#endif
cleri_node_t * node =
query->nodes->node->children->next->next->node->children->node;
query->nodes->node->children->next->node->children;
siridb_props_cb prop_cb;
-#if DEBUG
assert (query->packer == NULL);
-#endif
query->packer = sirinet_packer_new(4096);
/* get the callback */
prop_cb = siridb_props[children->node->children->node->
cl_obj->gid - KW_OFFSET];
-#if DEBUG
assert (prop_cb != NULL); /* all props are implemented */
-#endif
prop_cb(siridb, query->packer, 1);
if (children->next == NULL)
*/
siridb_series_decref(series);
-#if DEBUG
assert (q_select->alist->len >= 1);
-#endif
siridb_aggr_t * aggr = q_select->alist->data[0];
siridb_points_t * points;
while ( qp_is_raw(qp_next(unpacker, qp_name)) &&
-#if DEBUG
qp_is_raw_term(qp_name) &&
-#endif
qp_is_array(qp_next(unpacker, NULL)))
-
{
slist_t ** plist = (slist_t **) ct_getaddr(
q_select->result,
siridb_points_t * points,
uint64_t n)
{
-#if DEBUG
assert (points->len >= 2);
-#endif
int rc = 0;
uint64_t i, npivot, size_l, size_r;
siridb_points_t * points,
double percentage)
{
-#if DEBUG
assert (points->len >= 2);
-#endif
int rc = 0;
uint64_t i, npivot, size_l, size_r, n;
bool found_a, found_b;
*/
siridb_points_t * siridb_points_merge(slist_t * plist, char * err_msg)
{
-#if DEBUG
assert (plist->len >= 2);
-#endif
siridb_points_t * points;
siridb_points_t * tpts = NULL;
size_t n = 0;
i++;
}
-#if DEBUG
/* we have at least one series left */
assert (plist->len >= 1);
-#endif
if (plist->len == 1)
{
usleep(3000);
}
}
-#if DEBUG
/* size should be exactly zero */
assert (n == 0);
-#endif
}
usleep(3000);
}
}
-#if DEBUG
/* size should be exactly zero */
assert (n == 0);
-#endif
}
/*
}
}
-#if DEBUG
/* size should be exactly zero */
assert (n == 0);
-#endif
usleep(5000);
}
else
{
-#if DEBUG
/* we can only have 1 or 2 servers per pool */
assert (pool->len == 2);
-#endif
/* add the server to the pool, ordered by UUID */
if (siridb_server_cmp(pool->server[0], server) < 0)
{
}
else
{
-#if DEBUG
assert (siridb_server_cmp(pool->server[0], server) > 0);
-#endif
pool->server[1] = pool->server[0];
pool->server[0] = server;
*/
void siridb_pools_init(siridb_t * siridb)
{
-#if DEBUG
assert (siridb->pools == NULL);
assert (siridb->servers != NULL && siridb->servers->len > 0);
assert (siridb->server != NULL);
-#endif
siridb->pools = malloc(sizeof(siridb_pools_t));
if (siridb->pools == NULL)
pool->len = 0;
siridb_pool_add_server(pool, server);
pools->len++;
-#if DEBUG
+
assert (pools->prev_lookup == NULL);
-#endif
+
pools->prev_lookup = pools->lookup;
pools->lookup = lookup;
}
{
SIRIDB_PROP_MAP("time_precision", 14)
-#if DEBUG
assert (siridb->time->precision >= SIRIDB_TIME_SECONDS &&
siridb->time->precision <= SIRIDB_TIME_NANOSECONDS);
-#endif
qp_add_string(packer, siridb_time_short_map[siridb->time->precision]);
}
#include <sys/time.h>
#include <siri/err.h>
-#if DEBUG
-#include <motd/motd.h>
-#endif
-
#define QUERY_TOO_LONG -1
#define QUERY_MAX_LENGTH 8192
#define QUERY_EXTRA_ALLOC_SIZE 200
/* free handle */
free(handle);
-
- #if DEBUG
- log_debug("Free query!, hooray!");
- #endif
}
void siridb_send_query_result(uv_async_t * handle)
* clean everything without sending things in case of a client failure
*/
siridb_query_t * query = (siridb_query_t *) handle->data;
-#if DEBUG
- if (query->packer == NULL)
- {
- sprintf(query->err_msg, "CRITICAL: We have nothing to send!");
- return siridb_query_send_error(handle, CPROTO_ERR_QUERY);
- }
-#endif
+
+ assert (query->packer != NULL);
+
sirinet_pkg_t * pkg = sirinet_packer2pkg(
query->packer,
query->pid,
break;
case SIRIDB_QUERY_FWD_SOME_POOLS:
-#if DEBUG
-
assert (((query_select_t *) ((siridb_query_t *)
handle->data)->data)->tp == QUERIES_SELECT);
assert (((query_select_t *) ((siridb_query_t *)
handle->data)->data)->pmap != NULL);
-#endif
pkg->tp = BPROTO_QUERY_SERVER;
{
slist_t * borrow_list = imap_slist(((query_select_t *) (
siridb_query_t * query,
qp_unpacker_t * unpacker)
{
-#if DEBUG
assert (query->timeit != NULL);
-#endif
qp_types_t tp = qp_next(unpacker, NULL);
query->packer = sirinet_packer_new(512);
qp_add_type(query->packer, QP_MAP1);
-#ifndef DEBUG
- /* production version returns timestamp now */
siridb_t * siridb = query->client->siridb;
qp_add_raw(query->packer, (const unsigned char *) "calc", 4);
qp_add_int64(query->packer, (int64_t) (ts * factor));
}
-#else
- /* development release returns motd */
- const char * msg;
- msg = motd_get_random_msg();
- qp_add_raw(query->packer, (const unsigned char *) "motd", 4);
- qp_add_string(query->packer, msg);
-
-
-#endif
siridb_send_query_result(handle);
}
*/
void siridb_reindex_close(siridb_reindex_t * reindex)
{
-#if DEBUG
assert (reindex != NULL && reindex->timer != NULL);
-#endif
+
/* we can use uv_timer_stop() even if the timer is not scheduled */
uv_timer_stop(reindex->timer);
uv_close((uv_handle_t *) reindex->timer, (uv_close_cb) free);
*/
void siridb_reindex_free(siridb_reindex_t ** reindex)
{
-#if DEBUG
assert ((*reindex)->timer == NULL);
- log_debug("Free re-index");
-#endif
if ((*reindex)->fp != NULL && fclose((*reindex)->fp))
{
ERR_FILE
*/
void siridb_reindex_status_update(siridb_t * siridb)
{
-#if DEBUG
assert (~siridb->server->flags & SERVER_FLAG_REINDEXING);
assert (siridb->flags & SIRIDB_FLAG_REINDEXING);
-#endif
if (siridb_servers_available(siridb))
{
siridb->flags &= ~SIRIDB_FLAG_REINDEXING;
}
else
{
-#if DEBUG
assert (siri.optimize->pause);
-#endif
if (!SIRI_OPTIMZE_IS_PAUSED)
{
log_debug("Wait for the optimize task to pause");
static void REINDEX_send(uv_timer_t * timer)
{
siridb_t * siridb = (siridb_t *) timer->data;
-#if DEBUG
assert (siridb->reindex->pkg != NULL);
-#endif
/* actually 'available' is sufficient since the destination server has
* never status 're-indexing' unless one day we support down-scaling.
*/
siridb_t * siridb = (siridb_t *) timer->data;
siridb_reindex_t * reindex = siridb->reindex;
-#if DEBUG
assert (SIRI_OPTIMZE_IS_PAUSED);
assert (reindex != NULL);
assert (siridb->reindex->pkg == NULL);
-#endif
reindex->series = imap_get(siridb->series_map, *reindex->next_series_id);
* lock is not needed since we are sure the optimize task is
* not running
*/
-#if DEBUG
assert (siridb_lookup_sn(
siridb->pools->prev_lookup,
reindex->series->name) == siridb->server->pool);
-#endif
siridb_points_t * points = siridb_series_get_points(
reindex->series,
NULL,
*/
static int REINDEX_unlink(siridb_reindex_t * reindex)
{
-#if DEBUG
assert (reindex->fp != NULL);
-#endif
fclose(reindex->fp);
reindex->fp = NULL;
*/
int siridb_replicate_init(siridb_t * siridb, siridb_initsync_t * initsync)
{
-#if DEBUG
assert (siri.loop != NULL);
-#endif
siridb->replicate =
(siridb_replicate_t *) malloc(sizeof(siridb_replicate_t));
*/
void siridb_replicate_close(siridb_replicate_t * replicate)
{
-#if DEBUG
assert (replicate != NULL &&
replicate->timer != NULL &&
replicate->status != REPLICATE_CLOSED);
-#endif
/* we can use uv_timer_stop() even if the timer is not scheduled */
uv_timer_stop(replicate->timer);
uv_close((uv_handle_t *) replicate->timer, (uv_close_cb) free);
*/
void siridb_replicate_free(siridb_replicate_t ** replicate)
{
-#if DEBUG
- log_debug("Free replicate");
assert ((*replicate)->status == REPLICATE_CLOSED);
-#endif
if ((*replicate)->initsync != NULL)
{
siridb_initsync_free(&(*replicate)->initsync);
*/
void siridb_replicate_start(siridb_replicate_t * replicate)
{
-#if DEBUG
assert (siridb_replicate_is_idle(replicate));
-#endif
replicate->status = REPLICATE_RUNNING;
if (replicate->initsync == NULL)
{
*/
void siridb_replicate_pause(siridb_replicate_t * replicate)
{
-#if DEBUG
assert (replicate->status != REPLICATE_CLOSED);
-#endif
replicate->status = (replicate->status == REPLICATE_IDLE) ?
REPLICATE_PAUSED : REPLICATE_STOPPING;
}
*/
void siridb_replicate_continue(siridb_replicate_t * replicate)
{
-#if DEBUG
/* make sure the fifo buffer is open */
assert (siridb_fifo_is_open(((siridb_t *) replicate->timer->data)->fifo));
assert (replicate->status != REPLICATE_CLOSED);
-#endif
replicate->status = (replicate->status == REPLICATE_STOPPING) ?
REPLICATE_RUNNING : REPLICATE_IDLE;
siridb_t * siridb = (siridb_t *) handle->data;
sirinet_pkg_t * pkg;
-#if DEBUG
assert (siridb->fifo != NULL);
assert (siridb->replicate != NULL);
assert (siridb->replica != NULL);
assert (siridb->replicate->status != REPLICATE_CLOSED);
assert (siridb->replicate->initsync == NULL);
assert (siridb_fifo_is_open(siridb->fifo));
-#endif
if ( siridb->replicate->status == REPLICATE_RUNNING &&
siridb_fifo_has_data(siridb->fifo) &&
{
siridb_t * siridb = (siridb_t *) promise->data;
-#if DEBUG
/* open promises must be closed before siridb->replicate is destroyed */
assert (siridb->replicate != NULL);
assert (siridb->fifo != NULL);
-#endif
switch ((sirinet_promise_status_t) status)
{
uint64_t * ts,
qp_via_t * val)
{
-#if DEBUG
assert (!siri_err);
assert (series->buffer != NULL);
-#endif
int rc = 0;
series->length++;
siridb_shard_t * shard;
uint_fast32_t i;
-#if DEBUG
- if (siri.status == SIRI_STATUS_RUNNING || 0)
- {
- log_debug("Free series: '%s'", series->name);
- }
-#endif
-
/* mark shards with dropped series flag */
for (i = 0; i < series->idx_len; i++)
{
{
imap_t * dropped;
-#if DEBUG
/* we must have a server because we need to know the pool id */
assert (siridb->server != NULL);
-#endif
log_info("Loading series");
dropped = imap_new();
*/
int siridb_series_drop_commit(siridb_t * siridb, siridb_series_t * series)
{
-#if DEBUG
assert (series->flags & SIRIDB_SERIES_IS_DROPPED);
-#endif
int rc = 0;
(*required_shard)++;
-#if DEBUG
/* if not in the buffer, then if must be in a shard */
assert (series->idx_len);
-#endif
idx_t * first = series->idx;
&start,
series->flags & SIRIDB_SERIES_HAS_OVERLAP);
-#if DEBUG
/* we must have at least one point, more points are possible when
* having multiple points at the same time-stamp. */
assert (points->len);
-#endif
while (points->len > 1)
{
(*required_shard)++;
-
-#if DEBUG
/* if not in the buffer, then if must be in a shard */
assert (series->idx_len);
-#endif
/* if not in the buffer, then if must be in a shard */
NULL,
series->flags & SIRIDB_SERIES_HAS_OVERLAP);
-#if DEBUG
/* we must have at least one point, more points are possible when
* having multiple points at the same time-stamp. */
assert (points->len);
-#endif
while (points->len > 1)
{
size += idx->len;
end++;
-#if DEBUG
/*
* we have at least 2 references to the shard so we never
* reach 0 here. (this ref + optimize ref)
*/
assert(shard->replacing->ref >= 2);
-#endif
siridb_shard_decref(shard->replacing);
}
else if (idx->shard == shard && end)
}
while (idx->shard == shard);
-#if DEBUG
assert (idx->shard == shard->replacing);
-#endif
idx->shard = shard;
idx->start_ts = points->data[pstart].ts;
series->idx = idx;
}
}
-#if DEBUG
else
{
/* start must be equal to end if not smaller */
assert (i == end);
}
-#endif
if (series->flags & SIRIDB_SERIES_HAS_OVERLAP)
{
{
uint_fast32_t i;
-#if DEBUG
assert (series->flags & SIRIDB_SERIES_HAS_OVERLAP);
-#endif
+
for (i = 1; i < series->idx_len; i++)
{
if (series->idx[i - 1].end_ts > series->idx[i].start_ts)
series->flags |= SIRIDB_SERIES_IS_SERVER_ONE;
}
-#if DEBUG
/* make sure these two are exactly the same */
assert (siridb_series_server_id(series) ==
siridb_series_server_id_by_name(series->name));
-#endif
if (siridb->time->precision == SIRIDB_TIME_SECONDS)
{
void * data,
int flags)
{
-#if DEBUG
assert (server->client != NULL);
assert (server->promises != NULL);
assert (cb != NULL);
-#endif
int rc;
uint8_t n = 0;
sirinet_promise_t * promise =
void siridb_server_send_flags(siridb_server_t * server)
{
-#if DEBUG
assert (server->client != NULL);
assert (siridb_server_is_online(server));
-#endif
sirinet_stream_t * client = server->client;
-#if DEBUG
assert (client->siridb != NULL);
-#endif
int16_t n = client->siridb->server->flags;
QP_PACK_INT16(buffer, n)
*/
void siridb_server_connect(siridb_t * siridb, siridb_server_t * server)
{
-#if DEBUG
/* server->socket must be NULL at this point */
assert (server->client == NULL);
-#endif
server->client = sirinet_stream_new(STREAM_TCP_SERVER, &SERVER_on_data);
int siridb_server_drop(siridb_t * siridb, siridb_server_t * server)
{
int rc = 0;
-#if DEBUG
assert (siridb->server != server);
-#endif
siridb_pool_t * pool = siridb->pools->pool + server->pool;
switch (server->id)
{
case 0:
-#if DEBUG
assert (pool->len == 2);
-#endif
pool->server[0] = pool->server[1];
pool->server[0]->id = 0;
/* FALLTHRU */
siridb_server_decref(server);
rc = siridb_servers_save(siridb);
}
-#if DEBUG
else
{
+ /* can never be reached */
assert (0);
}
-#endif
return rc;
}
*/
void siridb__server_free(siridb_server_t * server)
{
-#if DEBUG
- log_debug("Free server: '%s'", server->name);
-#endif
/* we MUST first free the promises because each promise has a reference to
* this server and the promise callback might depend on this.
*/
char * tmp;
int fmt_as_ipv6 = 0; /* false */
-#if DEBUG
assert (server->port > 0);
-#endif
/* append 'string' length for server->port */
for (; i; i /= 10, len++);
/* append 'address' length */
len += strlen(server->address);
-#if DEBUG
assert (len > 0);
-#endif
/* allocate enough space */
tmp = (char *) realloc(server->name, len);
if (siridb->server->pool == server->pool)
{
/* this is a replica for 'this' pool */
-#if DEBUG
assert (siridb->replicate == NULL);
assert (siridb->fifo == NULL);
assert (siridb->replica == NULL);
-#endif
siridb->replica = server;
siridb->fifo = siridb_fifo_new(siridb);
/* this will close the file, even when other references exist */
siri_fp_decref(shard->fp);
-#if DEBUG
- log_debug("Free shard id: %" PRIu64, shard->id);
-#endif
-
free(shard->fn);
free(shard);
}
*/
void siridb__user_free(siridb_user_t * user)
{
-#if DEBUG
- log_debug("Free user: '%s'", user->name);
-#endif
free(user->name);
free(user->password);
free(user);
llist_node_t * siridb_node;
llist_node_t * server_node;
-#if DEBUG
log_debug("Start heart-beat task");
-#endif
siridb_node = siri.siridb_list->first;
{
uint_fast16_t i;
-#if DEBUG
- log_debug("Free help");
-#endif
-
for (i = 0; i < HELP_COUNT; i ++)
{
free(siri_help_content[i]);
int sirinet_bserver_init(siri_t * siri)
{
-#if DEBUG
assert (loop == NULL);
-#endif
int rc;
int ip_v6 = 0; /* false */
siridb_t * siridb = client->siridb;
if ((flags & INSERT_FLAG_POOL) && siridb->replica != NULL)
{
-#if DEBUG
assert (siridb->fifo != NULL);
-#endif
sirinet_pkg_t * repl_pkg;
if (siridb->replicate->initsync == NULL)
int sirinet_clserver_init(siri_t * siri)
{
-#if DEBUG
assert (loop == NULL && siri->loop != NULL);
-#endif
int rc;
int ip_v6 = 0; /* false */
*/
qp_packer_t * sirinet_packer_new(size_t alloc_size)
{
-#if DEBUG
assert (alloc_size >= sizeof(sirinet_pkg_t));
-#endif
qp_packer_t * packer = qp_packer_new(alloc_size);
if (packer == NULL)
uint8_t tp,
const char * msg)
{
-#if DEBUG
assert (msg != NULL);
-#endif
sirinet_pkg_t * pkg;
qp_packer_t * packer = sirinet_packer_new(len + 20 + sizeof(sirinet_pkg_t));
{
sirinet_stream_t * client = uvclient->data;
-#if DEBUG
- log_debug("Free socket client type: %d", client->tp);
-#endif
-
switch (client->tp)
{
case STREAM_PIPE_CLIENT:
*/
void siri_optimize_continue(void)
{
-#if DEBUG
assert (optimize.pause);
-#endif
if (!--optimize.pause && optimize.status == SIRI_OPTIMIZE_PAUSED_MAIN)
{
log_debug("Optimize task was paused by the main thread, continue...");
/* its possible that another database is paused, but we wait anyway */
if (optimize.pause)
{
-#if DEBUG
assert (optimize.status == SIRI_OPTIMIZE_RUNNING);
-#endif
optimize.status = SIRI_OPTIMIZE_PAUSED;
/* close open index file in case this is required */
*/
int siri_optimize_create_idx(const char * fn)
{
-#if DEBUG
assert (optimize.idx_fn == NULL && strlen(fn) > 3);
-#endif
+
/* copy file name */
optimize.idx_fn = strdup(fn);
if (optimize.idx_fn == NULL)
size_t j;
siridb = (siridb_t *) slsiridb->data[i];
-#if DEBUG
log_debug("Start optimizing database '%s'", siridb->dbname);
-#endif
uv_mutex_lock(&siridb->shards_mutex);
{
break;
}
-#if DEBUG
log_debug("Finished optimizing database '%s'", siridb->dbname);
-#endif
}
OPTIMIZE_cleanup(slsiridb);
}
char lname[255];
size_t len = strlen(siri.args->log_level);
-#ifndef DEBUG
+#ifdef NDEBUG
/* force colors while debugging... */
if (siri.args->log_colorized)
#endif
/* we do not expect any timer object since they should all be closed
* (or at least closing) at this point.
*/
-#if DEBUG
+#ifndef NDEBUG
LOGC( "Found a non closing Timer, all timers should "
"be stopped at this point.");
#endif
break;
case UV_ASYNC:
-#if DEBUG
+#ifndef NDEBUG
LOGC( "An async task is only expected to be found in case "
"not all tasks were closed within the timeout limit, "
"or when a critical signal error is raised.");
default:
-#if DEBUG
+#ifndef NDEBUG
LOGC("Oh oh, we might need to implement type %d", handle->type);
assert(0);
#endif